package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

public interface UserMapper {
    //根据openid查询用户信息
    @Select("select * from user where openid = #{openid}")
    User selectByOpenid(String openid);

    //新增用户
    @Options(useGeneratedKeys = true, keyProperty = "id") //返回主键id值
    @Insert("insert into user(openid, name, phone, sex, id_number, avatar, create_time) VALUES " +
            "(#{openid},#{name},#{phone},#{sex},#{idNumber},#{avatar},#{createTime})")
    void insert(User user);

    //根据id查询用户信息
    @Select("select * from user where id = #{id}")
    User selectById(Long id);
}
